<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>测试</title>
    <script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>
</head>
<body>
<div>
    <button id="test">显示</button>
</div>
<div>
    <input id="labelName" type="" name="" value="工程设计专业资质">
    <button id="show">查找</button>
</div>
</body>
<script type="text/javascript">
    let baseData;
    $.ajax({
        url: 'aptitude.json',
        type: 'post',
        dataType: 'json',
        success: function (res) {
            baseData = res;
        }
    });

    $("#show").click(function () {
        let labelName = $("#labelName").val();
        console.log(factSearchName(labelName, baseData));
    });

    function factSearchName(name, itemList) {

        let isGet = false;
        let retNode = null;

        function deepSearch(name, itemList) {
            for (let i = 0; i < itemList.length; i++) {
                if (itemList[i].children && itemList[i].children.length > 0) {
                    deepSearch(name, itemList[i].children);
                }
                if (name === itemList[i].dicName || isGet) {
                    isGet || (retNode = itemList[i]);
                    isGet = true;
                    break;
                }
            }
        }

        deepSearch(name, itemList);
        return retNode;
    }

</script>
</html>
